import { LockOutlined, UserOutlined } from '@ant-design/icons';
import { Button, Form, Input, message, Radio, Upload } from 'antd';
import { Link } from 'react-router-dom';
import Styles from '../../assets/styles/login.module.less';
import { Ilogin } from '../../types/user';
import { loginApi } from '../../apis/loginApi';
import { useHistory } from 'umi';
import { LoadingOutlined, PlusOutlined } from '@ant-design/icons';
import type { UploadChangeParam } from 'antd/es/upload';
import type { RcFile, UploadFile, UploadProps } from 'antd/es/upload/interface';
import React, { useState } from 'react';

export default function login() {
  const history = useHistory();

  const onFinish = async (values: Ilogin) => {
    let { username, password } = values;
    // username = 'mrbird';
    // values.username = 'bobo';
    // values.password = '1234qwer';
    const res: any = await loginApi(values);

    if (res.message == '认证成功') {
      // sessionStorage.setItem('username', username);
      sessionStorage.setItem('username', values.username);
      sessionStorage.setItem('token', res.data.token);
      message.info('登录成功', 0.8, () => {
        history.push('/home');
      });
    }
  };
  return (
    <div className={Styles.loginContainer}>
      <div className={Styles.loginContent}>
        <div className={Styles.loginContentTop}>
          <h3>阿杰养车</h3>
        </div>
        <div className={Styles.loginContentMain}>
          <Form
            name="normal_login"
            className="login-form"
            initialValues={{ remember: true }}
            onFinish={onFinish}
          >
            <Form.Item
              name="ssex"
              label="店铺类型"
              rules={[{ required: true }]}
            >
              <Radio.Group value={value}>
                <Radio value="0">充电桩</Radio>
                <Radio value="1">其他</Radio>
              </Radio.Group>
            </Form.Item>
            <Form.Item
              name="password"
              label="店铺名"
              rules={[{ required: true }]}
            >
              <Input />
            </Form.Item>
            <Form.Item
              name="password"
              label="手机号"
              rules={[{ required: true }]}
            >
              <Input />
            </Form.Item>
            <Form.Item
              name="password"
              label="店铺地址"
              rules={[{ required: true }]}
            >
              <Input />
            </Form.Item>
            <Form.Item
              name="password"
              label="注册人"
              rules={[{ required: true }]}
            >
              <Input />
            </Form.Item>
            <Form.Item
              name="password"
              label="身份证号"
              rules={[{ required: true }]}
            >
              <Input />
            </Form.Item>
            <Form.Item
              name="password"
              label="身份证照片"
              rules={[{ required: true }]}
            >
              <Input />
            </Form.Item>
            <div>
              <Link to="#">注册账户</Link>
              <Link to="/settled">商家入驻</Link>
            </div>
          </Form>
        </div>
      </div>
    </div>
  );
}
